package com.kyubi.xmlsynth;

import com.kyubi.common.config.Configuration;
import com.kyubi.common.data.InstanceToXMLConvertor;
import com.kyubi.common.data.Instances;
import com.kyubi.common.data.XMLToInstanceConvertor;
import com.kyubi.xmlsynth.source.IDataSource;
import com.kyubi.xmlsynth.source.SourceFactory;

/**
 * The class that converts files of various types of data sources in a unified XML format.
 * 
 * @author anand
 *
 */
public class XMLSynthesizer {
	
	private String filePath = null;
	private String outFilePath = null;
	
	/**
	 * 
	 * @param filePath	 the input data source file
	 * @param outFilePath	the output xml file
	 */
	public XMLSynthesizer(String filePath, String outFilePath) {
		this.filePath = filePath;
		this.outFilePath = outFilePath;
	}
	
	/**
	 * Perform the XML synthesis
	 */
	public void purge() {
		IDataSource source = SourceFactory.produceDataSource(filePath);
		Instances insts = source.get();
		InstanceToXMLConvertor xmlConvertor = new InstanceToXMLConvertor(insts, outFilePath);
		xmlConvertor.convert();
	}

	public static void main(String[] args) {
		Configuration config = Configuration.getSingleton(args[2]);
		XMLSynthesizer synth = new XMLSynthesizer(args[0], args[1]);
		synth.purge();		
	}

}
